package com.liao.ticket.controller;

import com.liao.ticket.service.AirportService;
import com.liao.ticket.vo.AirportVo;
import com.liao.ticket.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 接口测试成功
 * 10.13 21:28
 * 1.0.0
 */
@RestController
@RequestMapping("airport")
public class AirportQueryController {

    @Autowired
    private AirportService airportService;

    // 通过 机场id 查询 机场
    @GetMapping("one/by/id/{id}")
    public Result oneAirportById(@PathVariable Long id) {
        AirportVo airportVo = airportService.oneAirportVo(id);
        return Result.success(airportVo);
    }

    // 通过 地名 查询 机场列表
    @PostMapping("list/by/place")
    public Result listAirportVoByPlace(String placeName) {
        List<AirportVo> airportVoList = airportService.listAirportVoByPlace(placeName);
        return Result.success(airportVoList);
    }

    // 通过 机场名 查询 机场列表
    @PostMapping("list/by/airport")
    public Result listAirportVoByName(String name) {
        List<AirportVo> airportVoList = airportService.listAirportVoByName(name);
        return Result.success(airportVoList);
    }

    // 通过 机场名或地名 查询 机场列表
    @PostMapping("list/by/place/airport")
    public Result listAirportVoByPlaceOrName(String name) {
        List<AirportVo> airportVoList = airportService.listAirportVoByPlaceOrName(name);
        return Result.success(airportVoList);
    }

    // 通过 地点id 查询 机场列表
    @GetMapping("list/by/pid/{id}")
    public Result listAirportByPid(@PathVariable Integer id) {
        List<AirportVo> airportVoList = airportService.listAirportVoByPid(id);
        return Result.success(airportVoList);
    }

}
